<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员添加</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <include file="Index/common_css"/>
    <link href="__PUBLIC__/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
</head>

<body>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <form action="" method="post" class="form form-horizontal" id="form-admin-role-add" onsubmit="return false">

            <div class="form-group">
                <label class="col-sm-3 control-label">菜单名称：</label>
                <div class="col-sm-8">
                    <input id="menu_name" name="menu_name" value="{$data.menu_name}"  class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">菜单链接：</label>
                <div class="col-sm-8">
                    <input id="menu_href" name="menu_href" value="{$data.menu_href}" class="form-control" type="text"  datatype="*4-16" nullmsg="不能为空">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">所属节点：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="menu_parent" id="menu_parent">
                        <if condition="$data['menu_parent'] eq 0">
                            <option value="0">主节点</option>
                        <else/>
                            <foreach name="main_menu" item="main">
                                <option value="{$main.menu_id}"<if condition="$data['menu_parent'] eq $main['menu_id']">selected="selected"</if> >{$main.menu_name}</option>
                            </foreach>
                        </if>
                    </select>
                </div>
            </div>




            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button type="button" class="btn btn-success radius"  onclick="getCheckAdIds(this,'{$data.menu_id}')" id="admin-role-save" name="admin-role-save">
                        <i class="icon-ok"></i> 确定
                    </button>

                    <a style="margin-left: 20px;"onclick="layer_close();" class="btn btn-success btn-warning">
                        <i class="icon-ok"></i> 返回
                    </a>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 全局js -->
<include file="Index/common_js"/>
<!-- Peity -->

<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/common/js/layer_show.js"></script>

<!-- iCheck -->
<script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
<!-- Peity -->
<script>

    function getCheckAdIds(obj,id) {
        var menu_name= $("#menu_name").val();
        var menu_href= $("#menu_href").val();
        var menu_parent= $("#menu_parent").val();

        if(menu_name=='' || menu_href==''|| menu_parent=='') {
            layer.msg('不能有任何为空');
        } else {
            var index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            $.post('__MODULE__/System/power_saveData',{menu_id:id,menu_name:menu_name,menu_href:menu_href,menu_parent:menu_parent},function (data) {
                layer.close(index);
                if(data.status==1){
                    layer.msg(data.msg);
                    setTimeout(function () {location.reload();}, 1000);
                }else if(data.status==0){
                    layer.msg(data.error);
                }else{
                    layer.msg('网络错误');
                }
            })
        }
    }
</script>
</body>
</html>
